[FEAT] OAuth callback 처리 상태 관리 - #140
Conversation
- OAuth 요청에 ISSUED, PROCESSING, SUCCEEDED, FAILED 상태 추가 - callback 처리 선점과 중복 요청 방지 로직 구현 - 성공 및 단계별 실패 상태와 오류 분류 기록 - 장기 PROCESSING 요청 자동 실패 처리 - OAuth 상태 관리 DB 마이그레이션 추가 - 상태 전환, 부분 실패 및 동시 요청 테스트 추가
|
Warning Review limit reached
Next review available in: 4 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughOAuth 인가 요청에 ChangesOAuth 콜백 상태 관리
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant OAuthCallback as ExternalAccountOAuthService
participant RequestService as OAuthAuthorizationRequestService
participant RequestRepository as OAuthAuthorizationRequestRepository
participant ProviderClient as OAuth provider client
OAuthCallback->>RequestService: startProcessing(rawState, provider)
RequestService->>RequestRepository: ISSUED -> PROCESSING
RequestRepository-->>RequestService: ProcessingClaim
OAuthCallback->>ProviderClient: 토큰 교환 및 사용자 정보 조회
ProviderClient-->>OAuthCallback: 토큰 및 사용자 정보
OAuthCallback->>RequestService: succeed(requestId)
RequestService->>RequestRepository: PROCESSING -> SUCCEEDED
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@database/migrations/20260812_01_oauth_callback_status.sql`:
- Around line 8-12: Update the migration’s status backfill so used_at alone
never assigns SUCCEEDED; preserve ISSUED for unused records and assign legacy
records without independent success evidence to the project’s LEGACY or UNKNOWN
status. Keep used_at-based reuse prevention intact, and document the transition
according to RFC 6749 sections 4.1.2–4.1.3 and the project audit policy.
In
`@src/main/java/com/example/todayEng/domain/user/repository/OAuthAuthorizationRequestRepository.java`:
- Around line 71-85: Update the stale-condition comparison in
failStaleProcessing to use <= so requests with processingStartedAt exactly equal
to staleBefore are marked failed. Add a boundary test covering
processingStartedAt == staleBefore and verify the request is updated.
In
`@src/main/java/com/example/todayEng/domain/user/service/ExternalAccountOAuthService.java`:
- Around line 75-79: Bind externalAccountConnectionService.saveOrUpdate and
oauthAuthorizationRequestService.succeed into one completion transaction that
locks the request row and prevents the recovery scheduler from changing
PROCESSING during either operation. Update the relevant service transaction
boundaries while preserving OAuthCallbackFailureStage.ACCOUNT_SAVE handling, and
add an integration test covering scheduler execution between account persistence
and success completion.
In
`@src/test/java/com/example/todayEng/domain/user/repository/OAuthAuthorizationRequestRepositoryTest.java`:
- Around line 23-40: Update onlyOneCallbackCanAtomicallyStartProcessing to run
two callbacks concurrently using separate transactions and CountDownLatch
synchronization, following Spring TestContext transaction-testing conventions.
Have both attempts target the same issued request, assert that exactly one
result succeeds, and verify the final status is PROCESSING.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ce4566f-ccd5-41e4-9660-9b97f7c5024c
📒 Files selected for processing (12)
database/migrations/20260812_01_oauth_callback_status.sqlsrc/main/java/com/example/todayEng/domain/user/entity/OAuthAuthorizationRequest.javasrc/main/java/com/example/todayEng/domain/user/entity/enums/OAuthAuthorizationRequestStatus.javasrc/main/java/com/example/todayEng/domain/user/entity/enums/OAuthCallbackFailureStage.javasrc/main/java/com/example/todayEng/domain/user/entity/enums/OAuthCallbackFailureType.javasrc/main/java/com/example/todayEng/domain/user/repository/OAuthAuthorizationRequestRepository.javasrc/main/java/com/example/todayEng/domain/user/service/ExternalAccountOAuthService.javasrc/main/java/com/example/todayEng/domain/user/service/OAuthAuthorizationRequestRecoveryScheduler.javasrc/main/java/com/example/todayEng/domain/user/service/OAuthAuthorizationRequestService.javasrc/test/java/com/example/todayEng/domain/user/repository/OAuthAuthorizationRequestRepositoryTest.javasrc/test/java/com/example/todayEng/domain/user/service/ExternalAccountOAuthServiceTest.javasrc/test/java/com/example/todayEng/domain/user/service/OAuthAuthorizationRequestServiceTest.java
- 기존 OAuth 요청을 LEGACY 상태로 안전하게 백필 - 15분 경과 요청을 포함하도록 stale 조건 수정 - 계정 저장과 성공 상태 전환을 단일 트랜잭션으로 처리 - 완료 처리와 recovery scheduler 간 경쟁 조건 방지 - 실제 동시 callback 및 상태 전환 경계 테스트 추가
📌 관련 이슈
✨ 작업 내용
ISSUED,PROCESSING,SUCCEEDED,FAILED상태 추가ISSUED → PROCESSING원자적 상태 전환 구현SUCCEEDED처리FAILED처리PROCESSING요청 자동 실패 처리📸 UI 작업 시
X
✅ 체크 리스트
Summary by CodeRabbit
개선 사항
테스트